package com.atguigu.guli.service.edu.controller.api;


import com.atguigu.guli.service.base.result.R;
import com.atguigu.guli.service.edu.entity.Teacher;
import com.atguigu.guli.service.edu.service.TeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 讲师 前端控制器
 * </p>
 *
 * @author atguigu
 * @since 2021-06-24
 */
@Api(tags = "客户端讲师信息")
@RestController
@CrossOrigin
@RequestMapping("/api/edu/teacher")
public class ApiTeacherController {

    @Autowired
    private TeacherService teacherService;

    // 查询所有讲师
    @ApiOperation(value = "查询所有讲师")
    @GetMapping("getTeacherAll")
    public R getTeacherAll() {
        List<Teacher> teachers = teacherService.list();
        return R.ok().data("items", teachers);
    }

    // 查询讲师详细信息
    @ApiOperation(value = "查询讲师详细信息")
    @GetMapping("getTeacherById/{teacherId}")
    public R getTeacherById(@PathVariable("teacherId") String teacherId) {
        Teacher teacher = teacherService.getById(teacherId);
        return R.ok().data("item", teacher);
    }
}

